import React, { Component } from 'react'

export default class CountClass extends Component {
    constructor() {
        super();
        this.state = {
            count: 0
        }
    }
    componentDidMount() {
        document.title = `当前点击次数-${this.state.count}次`
    }
    componentDidUpdate() {
        document.title = `当前点击次数-${this.state.count}次`
    }
    addCount() {
        this.setState({
            count: this.state.count + 1
        })
    }
    render() {
        return (
            <div>
                <p>点击按钮，计数器的值就会增加-页面的title要显示当前点击的次数</p>
                <button onClick={() => this.addCount()}>{this.state.count}</button>
            </div>
        )
    }
}
